home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / ImageButtonBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  8KB  |  227 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  08/05/97    LAB    Removed ScaleMode and CenterMode properties.  Added ImageStyle property.
  8. //                    Removed connections associated with ScaleMode and CenterMode.  Added
  9. //                    connections related to ImageStle.
  10. //  09/07/97    LAB    Fixed misspelling of descriptions.  Removed background, foreground, and
  11. //                    font properties (Addresses Mac Bug #7668).
  12. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  13.  
  14. /**
  15.  * BeanInfo for ImageButton.
  16.  *
  17.  */
  18.  
  19. public class ImageButtonBeanInfo extends SimpleBeanInfo {
  20.  
  21.     /**
  22.      * Constructs a ImageButtonBeanInfo object.
  23.      */
  24.     public ImageButtonBeanInfo() {
  25.     }
  26.  
  27.     /**
  28.      * Gets a BeanInfo for the superclass of this bean.
  29.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  30.      */
  31.     public BeanInfo[] getAdditionalBeanInfo() {
  32.         try {
  33.             BeanInfo[] bi = new BeanInfo[1];
  34.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  35.             return bi;
  36.         }
  37.         catch (IntrospectionException e) { throw new Error(e.toString());}
  38.     }
  39.  
  40.     /**
  41.      * Gets the SymantecBeanDescriptor for this bean.
  42.      * @return an object of type SymantecBeanDescriptor
  43.      * @see symantec.itools.beans.SymantecBeanDescriptor
  44.      */
  45.     public BeanDescriptor getBeanDescriptor() {
  46.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  47.         String s=group.getString("GroupAWTAdditions"); 
  48.  
  49.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  50.         bd.setFolder(s);
  51.         bd.setWinHelp("0x123B0");
  52.  
  53.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  54.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  55.                                                 "%name%.IMAGE_TILED",
  56.                                                 conn.getString("IMAGE_TILED")));
  57.  
  58.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  59.                                                 "%name%.IMAGE_CENTERED",
  60.                                                 conn.getString("IMAGE_TILED")));
  61.  
  62.  
  63.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  64.                                                 "%name%.IMAGE_SCALED_TO_FIT",
  65.                                                 conn.getString("IMAGE_SCALED_TO_FIT")));
  66.  
  67.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  68.                                                 "%name%.NORMAL",
  69.                                                 conn.getString("NORMAL")));
  70.  
  71.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  72.  
  73.         return (BeanDescriptor) bd;
  74.     }
  75.  
  76.     /**
  77.      * Gets an image that may be used to visually represent this bean
  78.      * (in the toolbar, on a form, etc).
  79.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  80.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  81.      * @return an image for this bean, always color even if requested monochrome
  82.      * @see BeanInfo#ICON_MONO_16x16
  83.      * @see BeanInfo#ICON_COLOR_16x16
  84.      * @see BeanInfo#ICON_MONO_32x32
  85.      * @see BeanInfo#ICON_COLOR_32x32
  86.      */
  87.     public java.awt.Image getIcon(int iconKind) {
  88.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  89.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  90.             java.awt.Image img = loadImage("ImageButtonC16.gif");
  91.             return img;
  92.         }
  93.  
  94.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  95.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  96.             java.awt.Image img = loadImage("ImageButtonC32.gif");
  97.             return img;
  98.         }
  99.  
  100.         return null;
  101.     }
  102.  
  103.     /**
  104.      * Gets an array of descriptions of the methods used for "connections" by
  105.      * Visual CafΘ's Interaction Wizard.
  106.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  107.      * @return method descriptions for this bean
  108.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  109.      */
  110.     public MethodDescriptor[] getMethodDescriptors() {
  111.         Class[] args;
  112.         ConnectionDescriptor connection;
  113.         java.util.Vector connections;
  114.         java.util.Vector md = new java.util.Vector();
  115.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  116.  
  117.         try{
  118.             args = null;
  119.             MethodDescriptor getImageURL = new MethodDescriptor(beanClass.getMethod("getImageURL", args));
  120.  
  121.             connections = new java.util.Vector();
  122.             connection = new ConnectionDescriptor("output", "URL", "",
  123.                                     "%name%.getImageURL()",
  124.                                     conn.getString("getImageURL"));
  125.             connections.addElement(connection);
  126.  
  127.             getImageURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  128.             md.addElement(getImageURL);
  129.         } catch (Exception e) { throw new Error("getImageURL:: " + e.toString()); }
  130.  
  131.         try{
  132.             args = new Class[1];
  133.             args[0] = java.net.URL.class ;
  134.             MethodDescriptor setImageURL = new MethodDescriptor(beanClass.getMethod("setImageURL", args));
  135.  
  136.             connections = new java.util.Vector();
  137.             connection = new ConnectionDescriptor("input", "URL", "",
  138.                                     "%name%.setImageURL(%arg%);",
  139.                                     conn.getString("setImageURL"));
  140.             connections.addElement(connection);
  141.  
  142.             connection = new ConnectionDescriptor("input", "RelativeURL", "",
  143.                                     "%name%.setImageURL(symantec.itools.net.RelativeURL.getURL(%arg%));",
  144.                                     conn.getString("setImageURLRel"));
  145.             connections.addElement(connection);
  146.  
  147.             setImageURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  148.             md.addElement(setImageURL);
  149.         } catch (Exception e) { throw new Error("setImageURL:: " + e.toString()); }
  150.  
  151.         try{
  152.             args = new Class[1];
  153.             args[0] = java.lang.Integer.TYPE;
  154.             MethodDescriptor setImageStyle = new MethodDescriptor(beanClass.getMethod("setImageStyle", args));
  155.  
  156.             connections = new java.util.Vector();
  157.             connection = new ConnectionDescriptor("input", "int", "",
  158.                                     "%name%.setImageStyle(%arg%);",
  159.                                     conn.getString("setImageStyle"));
  160.             connections.addElement(connection);
  161.  
  162.             setImageStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  163.             md.addElement(setImageStyle);
  164.         } catch (Exception e) { throw new Error("setImageStyle:: " + e.toString()); }
  165.  
  166.         try{
  167.             args = null;
  168.             MethodDescriptor getImageStyle = new MethodDescriptor(beanClass.getMethod("getImageStyle", args));
  169.  
  170.             connections = new java.util.Vector();
  171.             connection = new ConnectionDescriptor("output", "int", "",
  172.                                     "%name%.getImageStyle()",
  173.                                     conn.getString("getImageStyle"));
  174.             connections.addElement(connection);
  175.  
  176.             getImageStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  177.             md.addElement(getImageStyle);
  178.         } catch (Exception e) { throw new Error("getImageStyle:: " + e.toString()); }
  179.  
  180.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  181.         md.copyInto(rv);
  182.  
  183.         return rv;
  184.     }
  185.  
  186.     /**
  187.      * Returns descriptions of this bean's properties.
  188.      */
  189.     public PropertyDescriptor[] getPropertyDescriptors() {
  190.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  191.         String s;
  192.  
  193.         try{
  194.         PropertyDescriptor imageURL = new PropertyDescriptor("imageURL", beanClass);
  195.         imageURL.setBound(true);
  196.         imageURL.setConstrained(true);
  197.         imageURL.setDisplayName(prop.getString("imageURL"));
  198.         imageURL.setValue("URLFILTER", prop.getString("imageURLFILTER"));
  199.  
  200.         PropertyDescriptor imageStyle = new PropertyDescriptor("imageStyle", beanClass);
  201.         imageStyle.setBound(true);
  202.         imageStyle.setConstrained(true);
  203.         imageStyle.setDisplayName(prop.getString("imageStyle"));
  204.         imageStyle.setValue("ENUMERATION", "IMAGE_TILED=0, IMAGE_CENTERED=1, IMAGE_SCALED_TO_FIT=2, IMAGE_NORMAL=3");
  205.  
  206.         PropertyDescriptor background = new PropertyDescriptor("background", beanClass);
  207.         background.setHidden(true);
  208.  
  209.         PropertyDescriptor foreground = new PropertyDescriptor("foreground", beanClass);
  210.         foreground.setHidden(true);
  211.  
  212.         PropertyDescriptor font = new PropertyDescriptor("font", beanClass);
  213.         font.setHidden(true);
  214.  
  215.         PropertyDescriptor[] rv = {
  216.             imageURL,
  217.             imageStyle,
  218.             background,
  219.             foreground,
  220.             font};
  221.         return rv;
  222.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  223.     }
  224.  
  225.     private final static Class beanClass = ImageButton.class;
  226.  
  227.     }    //  end of class ImageButtonBeanInfo